package com.yongjie.springbootlogin.service;

import com.yongjie.springbootlogin.entity.Login;
import com.yongjie.springbootlogin.mapper.LoginMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    @Autowired
    LoginMapper loginMapper;
    /*用户登录*/
    public Login findByuser(String username,String password){
        Login login=loginMapper.findByuser(username,password);
        return login;
    }
    //注册用户
    public int adduser(String username,String password,int age){
//        return userMapper.adduser(username,password,age);
        /*注册用户方式2*/
        return loginMapper.adduser(username,password,age);
    }
    //注册医生账户
    public  int addUserDoctor(String username,String password,int age){
        return loginMapper.addUserDoctor(username,password,age);
    }
    //根据用户名查询id
    public  String finIdByusername(String username){
        return loginMapper.finIdByusername(username);
    }
    //查询是否用户名存在
        public Boolean finusernameByusername(String username){
            String str = loginMapper.finIdByusername(username);
            if(str!=null || "".equals(str)){
                return false;
            }else {
                return true;
            }
    }
}
